package com.yc.streamamq.controller;

import com.yc.streamamq.util.SourceOut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SendMessageController {

    @Autowired
    private SourceOut source;

    @GetMapping("/sendMessage")
    public Object sendMessage(String message){
        MessageBuilder<String> messageBuilder = MessageBuilder.withPayload(message);
        source.message().send(messageBuilder.build());
        System.out.println("消息发送成功>>>"+message);
        return "消息发送成功>>>"+message;
    }

}
